// 进程
// console.log(process.argv[2])

// test.ts -> test.ts -> .js运行

const path=require('path')
const ts=require('typescript')
const fs=require('fs')

const filePath=process.argv[2]; // test.ts

//  require 关键字 node 模块化
require.extensions['.ts'] = function(module,filename){
    // console.log(module,filename)
    const fileFullPath = path.resolve(__dirname,filename)
    // 同步的同时也是阻塞的
    const content = fs.readFileSync(fileFullPath,'utf-8')
    // .ts -> .js 
    const {outputText}=ts.transpileModule(content,{
        compilerOptions:{}
    })
    // console.log(outputText)
    // 编译 lazy load router component
    module._compile(outputText,filename)
}
require(filePath)